<!DOCTYPE html>

<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <meta
            name="viewport"
            content="width=device-width, initial-scale=1.0, user-scalable=no"
        />
        <meta http-equiv="X-UA-Compatible" content="ie=edge" />
        <title>JavaScriptPromise</title>
    </head>

    <body>
        <script>
            let p1 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve("p1");
                }, 1000);
            });

            let p2 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    reject("p2");
                }, 1500);
            });

            let p3 = new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve("p3");
                }, 500);
            });

            // let res = Promise.all([p1, p2, p3]);
            // console.log(res);

            // Promise.allSettled([p1, p2, p3]).then((a) => {
            //     console.log(a);
            // });
            // console.log(res2);

            // Promise.all([p1, p2, p3])
            //     .then((res) => {
            //         console.log(111, res);
            //     })
            //     .catch((err) => {
            //         console.log(err); // p2
            //     });

            // let res = Promise.any([p1, p2, p3]);
            // console.log(res);

            // let res = Promise.race([p1, p2, p3]);
            // console.log(res);

            // let rej = Promise.reject("123");
            // console.log(rej);

            // let res = Promise.resolve({ name: "Best Shi" });
            // console.log(res);

            new Promise((resolve, reject) => {
                throw "error";
            }).catch((res) => {
                console.log(res);
            });
        </script>
    </body>
</html>
